package org.aiesec.fortaleza.xmatch.model.util;

public class SimpleExpression {
	private String property;
	private Object value;
	private String operation;

	public SimpleExpression(String property, Object value, String operation) {
		super();
		this.property = property;
		this.value = value;
		this.operation = operation;
	}

	public String getOperation() {
		return operation;
	}

	public void setOperation(String operation) {
		this.operation = operation;
	}

	public String getProperty() {
		return property;
	}

	public void setProperty(String property) {
		this.property = property;
	}

	public Object getValue() {
		return value;
	}

	public void setValue(Object value) {
		this.value = value;
	}

	public boolean isAvaible() {
		if (value != null) {
			if (value instanceof Number) {
				Number numberValue = (Number) value;
				if (numberValue instanceof Short || numberValue instanceof Byte
						|| numberValue instanceof Integer
						|| numberValue instanceof Long) {
					return numberValue.longValue() > 0;
				} else if (numberValue instanceof Float
						|| numberValue instanceof Double) {
					return numberValue.doubleValue() > 0;
				}
			} else if (value instanceof String) {
				String valueString = (String) value;
				return valueString.trim().length() > 0;
			}
			return true;
		}
		return false;
	}

	public String getScrapQuery(String param) {
		return property + operation + ":" + param;
	}
}
